﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Agresso.Interface.Layer.Service;
using Agresso.Interface.Layer.Domain;

namespace Agresso.Interface.Layer.WinServiceTest
{
    class Program_3
    {
        static DateTime lastexecuteDate;
        static void Main(string[] args)
        {
            TaskSchedule tc = new TaskSchedule("TCRelet", 15000, new TaskSchedule.Job(ExecuteCommissionInvoiceTCReletType));
            Console.WriteLine("Service started... at :" + DateTime.Now);
            Console.ReadLine();
        }
        private static void ExecuteCommissionInvoiceTCReletType()
        {
            DateTime time = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, 0);
            bool lastexecute = lastexecuteDate == time;
            if (!lastexecute)
            {
                Console.WriteLine(string.Format("Execute Commission Invoice TC Relet Type Interface on {0}", DateTime.Now));
                CommissionInvoiceService commissionInvoiceService = new CommissionInvoiceService();
               // commissionInvoiceService.ExecuteCommissionInvoiceTCReletType();
                ConfigurationSettingService confService = new ConfigurationSettingService();
                ConfigurationSetting cs = confService.GetConfigurationSetting("TCRelet");
                cs.val_10 = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
                confService.UpdateConfiguration(cs);
                lastexecuteDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, 0);
            }
        }
    }
}
